package com.zzty.txj1.dao;


import com.zzty.txj1.entity.SelfExam;
import com.zzty.txj1.entity.SelfExamTransaction;
import com.zzty.txj1.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface SelfExamTransactionDao {
    @Select("select * from selfExamTransaction where selfExamId=#{selfExamId} and userId=#{userId}")
    SelfExamTransaction checkFirstLogIn(SelfExamTransaction selfExamTransaction);

    @Insert("insert into selfExamTransaction (selfExamId,userId,startTime) values (#{selfExamId},#{userId},#{startTime})")
    Integer initSelfExamTransaction(SelfExamTransaction selfExamTransaction);

    @Select("select startTime from selfExamTransaction where selfExamId=#{selfExamId} and userId=#{userId}")
    String getStartTime(SelfExamTransaction selfExamTransaction);

    @Update("update selfExamTransaction set answerUrl=#{answerUrl},spendTime=#{spendTime} where " +
            "selfExamId=#{selfExamId} and userId=#{userId}")
    Integer updateUrlSpendTime(SelfExamTransaction selfExamTransaction);

    @Select("select * from selfExamTransaction where userId=#{id}")
    List<SelfExamTransaction> getSelfExamTransaction(User user);

    
}
